// 用户
const mongoose = require('mongoose')


/*
获取选项配置
既可以作为参数
也可以作为显示
  "gender": [
            {
                "key": 1,
                "val": "男"
            },
            {
                "key": 2,
                "val": "女"
            },
            {
                "key": 3,
                "val": "保密"
            }
        ],
https://wx5a691zs0.jobs.feishu.cn/api/v1/common/setting
https://jobs.bytedance.com/api/v1/common/setting
*/
const ResumesSchema = new mongoose.Schema({
    // 用户id
    user_id: {
        type: String,
        required: true
    },
    // mongoose默认产生的字段，不需要展示
    __v: {
        type: Number,
        select: false
    },
    // 附件简历
    // 通过接口上传和下载
    // https://wx5a691zs0.jobs.feishu.cn/api/v1/attachment/download/links
    resume_attachment: {
        "id": { type: String },
        "name": { type: String },
        "create_time": { type: Number }
    },
    // 基本信息
    name: {
        type: String,
        required: true
    },
    email: {
        type: String,
        required: true
    },
    gender: {
        type: String,
        //枚举，只能是这两个值
        // enum: ['male', 'female', 'secrecy'],
        required: true
    },
    mobile_number: {
        type: String,
        required: true
    },
    // 教育经历
    education_list: {
        type: [{
            // 学校
            school: { type: String },
            // 专业
            major: { type: String },
            // 学历 1高中及以下 2大专 3本科 4硕士 5博士及以上
            // diploma: {type: Number, enum: [1, 2, 3, 4, 5]},
            diploma: { type: Number },
            // 起止时间
            start_time: { type: Number },
            end_time: { type: Number },
        }]
    },
    // 工作经历
    career_list: {
        type: [{
            // 公司名称
            company: { type: String },
            // 职位名称
            title: { type: String },
            description: { type: String },
            start_time: { type: String },
            end_time: { type: String },
        }]
    },
    // 实习经历
    internship_list: {
        type: [{
            // 公司名称 
            company: { type: String },
            // 职位名称
            title: { type: String },
            description: { type: String },
            start_time: { type: String },
            end_time: { type: String },
        }]
    },
    // 项目经历
    project_list: {
        type: [{
            name: { type: String },
            // 角色
            role: { type: String },
            start_time: { type: String },
            end_time: { type: String },
            link: { type: String },
            description: { type: String },
        }]
    },
    // 作品
    works_list: {
        type: [{
            link: { type: String },
            description: { type: String },
            //    附件 
            "works_attachment": {
                "id": { type: String },
                "name": { type: String },
                "create_time": { type: Number }
            },
        }]
    },
    // 获奖
    award_list: {
        type: [{
            title: { type: String },
            award_time: { type: Array },
            description: { type: String },
        }]
    },
    // 语言
    language_skill_list: {
        type: [{
            language: { type: String },
            proficiency: { type: String },
        }]
    },

    // 自我评价
    self_evaluation: {
        type: String
    },
    sns_list: {
        type: [{
            sns_type: { type: Number },
            link: { type: String },
        }]
    }

}, { timestamps: true })
module.exports = mongoose.model('Resumes', ResumesSchema)


const c = {
    "resume_id": "7290156397701679419",
    "name": "王家辉",
    "country_code": "CN_1",
    "mobile_number": "16675546271",
    "email": "shunxuan_you@qq.com",
    "gender": 3,
    "portal_attachment_id": "7290168458011707685",
    "identification": {},
    "education_list": [
        {
            "major": "计算机",
            "start_time": 1672502400000,
            "end_time": -1,
            "school": "黄冈职业技术学院",
            "degree": 5,
            "customized_data": []
        }
    ],
    "career_list": [
        {
            "description": "描述",
            "start_time": 1675180800000,
            "end_time": 1675180800000,
            "company": "商汤科技",
            "title": "前端开发工程师",
            "customized_data": []
        }
    ],
    "project_list": [
        {
            "description": "项目描述",
            "start_time": 1680278400000,
            "end_time": 1685548800000,
            "name": "中后台项目",
            "role": "前端开发",
            "link": "http://123.60.177.34/",
            "customized_data": []
        }
    ],
    "internship_list": [
        {
            "description": "描述",
            "position": "前端开发",
            "start_time": 1530374400000,
            "end_time": 1556640000000,
            "company": "前锦网络",
            "customized_data": []
        }
    ],
    "works_list": [
        {
            "link": "https://shunxuanyou.github.io/",
            "description": "作品描述",
            "customized_data": []
        }
    ],
    "award_list": [
        {
            "award_time": 1514736000000,
            "title": "什么杯奖",
            "desc": "获奖描述",
            "customized_data": []
        }
    ],
    "competition_list": [],
    "certificate_list": [],
    "language_skill_list": [
        {
            "language": 3,
            "proficiency": 1,
            "customized_data": []
        }
    ],
    "sns_list": [
        {
            "sns_type": 3,
            "link": "16675546271",
            "customized_data": []
        }
    ],
    "application_preferred_city_list": null,
    "accept_transfer_preferred_city": 2,
    "formControlChangeFlag": "18",
    "customized_data": {
        "7283416496868608317": [
            {
                "object_id": "7283416496868608317",
                "children": [
                    {
                        "object_id": "7283416496868919613",
                        "value": "自我评价"
                    }
                ]
            }
        ]
    }
}